import Storage from '@/lib/storage'
import { setThemeColor } from '@/lib/theme.js'
const LocalStorage = new Storage('', 'localStorage')

const state = {
    themeModule: LocalStorage.getItem('themeModule') || {}
}

const mutations = {
    CHANGE_MAIN_COLOR: (state, payload) => {
        state.themeModule[payload.themeModule] = payload.color;

        setThemeColor(payload.themeModule, payload.color);
    }
}

const actions = {
    changeMainColor({ commit }, payload) {
        commit('CHANGE_MAIN_COLOR', payload);
    }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
